/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-20 21:30:17
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-22 13:14:58
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/controller/visitor_controller.dart';
import 'package:flutter_data_center/utills/color_utils.dart';
import 'package:get/get.dart';

class VisitorMenu extends StatelessWidget {
  const VisitorMenu({Key key, this.currentIndex, this.onTap}) : super(key: key);
  final int currentIndex;
  final ValueChanged<int> onTap;

  @override
  Widget build(BuildContext context) => GetBuilder<VisitorController>(
      builder: (_controller) => Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: List.generate(
              _controller.menus.length,
              (index) => InkWell(
                borderRadius: BorderRadius.circular(50),
                onTap: () {
                  _controller.changeType(_controller.menus[index].key);
                },
                child: Container(
                  alignment: Alignment.center,
                  margin: EdgeInsets.only(right: 20),
                  width: 63,
                  height: 27,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(50),
                    color:
                        _controller.visitorType == _controller.menus[index].key
                            ? Theme.of(context).primaryColor
                            : gColor("#E6F0EC"),
                  ),
                  child: Text(
                    _controller.menus[index].value,
                    style: TextStyle(
                      fontSize: 16,
                      height: 1,
                      color: _controller.visitorType ==
                              _controller.menus[index].key
                          ? Colors.white
                          : Colors.black,
                    ),
                  ),
                ),
              ),
            ).toList(),
          ));
}
